package cn.school.controller.prevention;

import cn.school.common.api.CommonPage;
import cn.school.common.api.CommonResult;
import cn.school.prevention.entity.FeedBack;
import cn.school.prevention.service.FeedBackService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "t_prevention_feedback_detail => 防控反馈详情表")
@RequestMapping("/feedback")
public class FeedBackController {

    @Autowired
    private FeedBackService feedBackService;


    @ApiOperation("feedBackPageList => 分页查询反馈详情表")
    @PostMapping(value = "/feedBackPageList")
    public CommonResult<CommonPage<FeedBack>> feedBackPageList(@RequestBody FeedBack feedBack) {
        IPage<FeedBack> feedBackPageList = feedBackService.FeedBackPageList(feedBack);
        return CommonResult.success(CommonPage.restPage(feedBackPageList));
    }

    @ApiOperation("updateFeedBack => 修改反馈详情表")
    @PostMapping("/updateFeedBack")
    public CommonResult<Integer> updateFeedBack(@RequestBody FeedBack feedBack) {
        int num = feedBackService.update(feedBack);
        if (num > 0) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

    @ApiOperation("listFeedBack => 查询反馈详情表")
    @PostMapping("/listFeedBack")
    public CommonResult<List<FeedBack>> listFeedBack(@RequestBody FeedBack feedBack) {
        List<FeedBack> list = feedBackService.list(feedBack);
        return CommonResult.success(list);
    }
}
